﻿using Xejen.Communication.Configuration;
using Xejen.Communication.Endpoints;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Xejen.Communication.Logger
{
    /// <summary>
    /// 表示数据库记录，用于记录通信接口的访问记录
    /// </summary>
    /// <creator>marc</creator>
    public interface IDatabaseLogger
    {
        /// <summary>
        /// 将请求记录保存到数据库中
        /// </summary>
        /// <param name="logData"><inheritdoc cref="ILogData{TCommunicationAddress, TResponse}" path="/summary"/></param>
        /// <param name="config"><inheritdoc cref="ICommunicator{TCommunicationConfig, THeartbeatConfig}.Config" path="/summary"/></param>
        /// <param name="cancellationToken">线程取消令牌</param>
        /// <returns></returns>
        Task SaveAsync<TCommunicationConfig, THeartbeatConfig, TCommunicationAddress, TResponse>(ILogData<TCommunicationAddress, TResponse> logData, TCommunicationConfig config, CancellationToken cancellationToken = default)
            where TCommunicationConfig : CommunicationConfig<THeartbeatConfig>, new()
            where THeartbeatConfig : HeartbeatConfig, new()
            where TResponse : IResult;
    }
}
